unit Plugin;

{$mode objfpc}{$H+}

interface

uses
  Lx_Result,
  Lx_Server,
  Lx_IO    ,
  Lx_Image ,
  Lx_Log   ;

type

  { TSaver }

  TSaver = class(TLxSaver)
    function  Save(      Source   : IUnknown;
                   const Filename : PChar   ;
                         Monitor  : IUnknown) : LxResult      ; override;
  end;

implementation

uses
  SysUtils;

function  TSaver.Save(      Source   : IUnknown;
                      const Filename : PChar   ;
                            Monitor  : IUnknown) : LxResult;
var
  W, H  : UInt32;
begin
  ILxImage(Source).Size(@W, @H);

  with ILxLogService(GetService(ILxLogService)) do
    DebugLogOutput(LXi_DBLOG_NORMAL,
                   PChar('Hello world: image ' + Filename    +
                                        ' is ' + IntToStr(W) +
                                        ' x '  + IntToStr(H) + NL));

  Result := LXe_OK;
end;

initialization
  AddServer('helloWorld', TSaver, [LXsSAV_OUTCLASS, LXa_IMAGE    ,
                                   LXsSAV_DOSTYPE , 'HEL'        ,
                                   LXsSRV_USERNAME, 'Hello World']);

end.

